from config.MyConfig import MyConfig
# from trainAndTest import trainV3_2 as Train
from trainAndTest import trainV3_2 as Train
from other import PrintSignalLine
from trainAndTest import testTrainV2
import torch

myConfig = MyConfig()
myConfig.logFileDir = r"E:/Documents/Documents/Python/大创/log"
myConfig.logFileName = r"train_machine_Multi_Tune2.xlsx"  # xlsx文件
# myConfig.modelDataSetRootPath = r"/root/data/newData"
# myConfig.modelDataSetRootPath = r"F:/DataSet/P300_2022Dataset"
myConfig.modelDataSetRootPath = [r"F:/DataSet/P300_2022Dataset/s53.mat"]
myConfig.modelFilePath=r"E:/Documents/Documents/Python/大创/资料/比较好的记录/MultiPer/2025-2-18/model_multiPer_853_307Len.pth"
# myConfig.modelSaveRootPath = r"/root/data/modelSave"
myConfig.modelSaveRootPath = r"E:/Documents/Documents/Python/大创/modelSave"
myConfig.batchSize = 64
myConfig.splitRate = 0.9
myConfig.epoch = 100
myConfig.num_classes = 2
myConfig.machineDataFile=r"F:/DataSet/data/trainData"
myConfig.dataAChannel=(16,19,31)
myConfig.dataBChannel=[4,5,6]   #第一列是Index不是数据
myConfig.machineDataTargetWordDict=r"F:/DataSet/data/TargetWord.json"
myConfig.machineDataCSVDelimiter="\t"
myConfig.machineDataLabel=22

choiceFunc=0

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

def runTrain():
    # Train.train(myConfig, False)
    Train.train(myConfig,True)


def runPrintGraph():
    PrintSignalLine.printSignalLine(myConfig)


def runTest():
    testTrainV2.test(myConfig)


def runTestModel():
    from torchsummary import summary
    # model = Multi_featureV2_2_modify.multi_person_feature(1, 2).to(device)
    # print(summary(model, (1, 6, 12)))
    # from modelSource import SepConv1D
    # print(summary(SepConv1D.SepConv1DNet().to(device),(6,307)))
    from modelSource import Multi_featureV2_3_modify
    print(summary(Multi_featureV2_3_modify.multi_person_feature(1, 2).to(device), (1, 6, 307)))


def runPredict():
    from other import GetPredict
    # GetPredict.predict(r"/root/data/newData/s01.mat",r"/root/data/modelSave/save/sep1D_86.pth")
    # GetPredict.predict2022DataSet(r"/root/data/someData/s53.mat", myConfig.modelFilePath)
    GetPredict.predictMachine(myConfig)
    # 最好 model_MultiPer_875_307
    # 53最好


def printParam():
    from torchsummary import summary
    
    # model = Multi_featureV2_2_modify.multi_person_feature(1, 2).to(device)
    # print(summary(model, (1, 6, 12)))
    # from modelSource import SepConv1D
    # print(summary(SepConv1D.SepConv1DNet().to(device),(6,307)))
    from modelSource import Multi_featureV2_3_modify
    model = Multi_featureV2_3_modify.multi_person_feature(1, 2).to(device)
    for name, param in model.named_parameters():
        print("name: {}, param: {}".format(name, param.size()))


if __name__ == '__main__':
    match choiceFunc:
        case 0:
            runTrain()
        case 1:
            runPrintGraph()
        case 2:
            runTest()
        case 3:
            runTestModel()
        case 4:
            runPredict()
        case 5:
            printParam()
    print("End!")
